package com.dailyblue.java.thread;

import java.util.concurrent.locks.ReentrantLock;

public class DemoE1 {
    private Integer i = 1;
    private ReentrantLock lock = new ReentrantLock();

    public void change() {
        // 上锁
        lock.lock();
        System.out.println(Thread.currentThread().getName() + "准备对i进行操作，目前i的值是：" + i);
        this.i++;
        System.out.println(Thread.currentThread().getName() + "执行完毕，目前i的值是：" + i);
        // 解锁
        lock.unlock();
    }
}
